<?php
    /* 
    *接口说明:  获取用户点餐的记录列表
    *创建者: 	kai
    *时间:	  	20180410
    */
    // 设置时区
    date_default_timezone_set('Etc/GMT-8');
    // 包含共通文件
    require_once 'commom/config.php';
    require_once 'commom/dbbase.php';

    $arrResult = null;
    
    do{
        // 参数检查
        $json_infoString = isset($_GET['info']) ? $_GET['info'] : '';
        if(empty($json_infoString)){
            $arrResult = array(
                        "errcode" => 1,
                        "info" => "get参数为空",
                        );
            break;
        }

        // 从传入参数中获取需要的信息
        $json_info = json_decode($json_infoString, true);
        // 获取信息
        $wechatopenid = "";
        $no = 0;
        if(isset($json_info['wechatopenid'])){
			$wechatopenid = $json_info['wechatopenid'];
        }
        if(isset($json_info['no'])){
			$no = $json_info['no'];
        }

        // 参数检查
        if(empty($publisheropenid)){
            $arrResult = array(
                "errcode" => 2,
                "info" => "上传信息不足. wechatopenid=".$wechatopenid,
                );
            break;
        }

        // 根据shareuniqueid和publisheropenid获取分享的记录
        $QuerySql = "select * from orderstatshare where wechatopenid='" . $wechatopenid."' order by no desc limit 100";

        // 更新数据库记录标志
        $mysqlAcc = new mysql_acc(DB_HOST, DB_USER, DB_PWD, DB_DBNAME);
        if($mysqlAcc->getlasterrcode() != 0){
            $arrResult = array(
                "errcode" => 3,
                "info" => "获取数据库链接失败。errinfo:".$mysqlAcc->getlasterrinfo(),
                );
            break;
        }

        $arrMysqlResult = $mysqlAcc->dbexecute($QuerySql, true);
        // 判断查询结果
        if($arrMysqlResult["errcode"] != 0){
            $arrResult = array(
                "errcode" => 4,
                "info" => $arrMysqlResult["errinfo"],
                );
        }
        // 输出结果
		$arrResult = array(
            "errcode" => 0,
            "info" => json_encode($arrMysqlResult["result"]),
            );
    }while(false);

    // 输出结果
    echo json_encode($arrResult);
?>